import { _decorator, Component, Label, loader, Node, resources, Sprite, SpriteFrame, } from 'cc';
import { UICtrl } from '../Framework/Managers/UICtrl';
import { UIMgr } from '../Framework/Managers/UIMgr';
import { ResMgr } from '../Framework/Managers/ResMgr';
const { ccclass, property } = _decorator;

@ccclass('RankingBox_Ctrl')
export class RankingBox_Ctrl extends UICtrl {
    @property(Label)
    private palyerName:Label;
  
    @property(Label)
    private rank:Label;
    @property(Sprite)
    private avatar:Sprite;
    @property(Sprite)   
    private ranking_goldmedal:Sprite;
    start() {

    }
    onLoad(){
        super.onLoad();
        
    }
    init(rank:number,avatar,palyerName,num) {
        if(rank == 1){
            this.rank.node.active = false;
            this.ranking_goldmedal.node.active = true;
            this.ranking_goldmedal.spriteFrame = ResMgr.Instance.getAsset("GUI","GameUI/Ranking/ranking_goldmedal/spriteFrame");
            
        }else if(rank == 2){
            this.rank.node.active = false;
            this.ranking_goldmedal.node.active = true;
            this.ranking_goldmedal.spriteFrame = ResMgr.Instance.getAsset("GUI","GameUI/Ranking/ranking_silver_medal/spriteFrame");
        }else if(rank == 3){
            this.rank.node.active = false;
            this.ranking_goldmedal.node.active = true;
            this.ranking_goldmedal.spriteFrame = ResMgr.Instance.getAsset("GUI","GameUI/Ranking/ranking_bronze/spriteFrame");
        }else{
            this.rank.getComponent(Label).string = rank+"";
        }
        this.palyerName.getComponent(Label).string = palyerName+"";
        // resources.load("",SpriteFrame, (err: any, spriteFrame) => {
        //     this.avatar.getComponent(Sprite).spriteFrame = spriteFrame;
        //   });
        
        
    }
    update(deltaTime: number) {
        
    }
}


